package com.joinway.framework.extension.net;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;

public final class FTPClientExampleCompact
{

    public static void main(String[] args) throws Exception
    {
        String server = "183.62.44.67";

        FTPClient ftp = new FTPClient();
        
        
//        ftp.setListHiddenFiles(false);
        ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
        
        ftp.connect(server);
        ftp.enterLocalPassiveMode();
        ftp.login("NS_TEST", "ns@test");
        ftp.setFileType(FTP.ASCII_FILE_TYPE);
        
//        ftp.setUseEPSVwithIPv4(false);
        
        OutputStream output = new FileOutputStream("I:\\aa.txt");
        ftp.retrieveFile("NS_TEST/OUT/test.txt", output);
        output.close();
//        ftp.noop(); // check that control connection is working OK
        ftp.logout();
    }
}

